<template>
  <div class="home-container">
    <el-card class="box-card">
      <div class="personal">
        <div class="list">
          <h1>欢迎进入 后台管理系统</h1>
        </div>
        <el-divider></el-divider>
        <div style="margin-bottom: 15px;font-size: 25px;">
          <h5>数据总览</h5>
        </div>
        <div style="font-size: 20px;">
          <div>
            当前账户数： {{ main_statistics_info.accountNum }}
          </div>
          <el-divider></el-divider>
          <div>
            当前用户数： {{ main_statistics_info.userNum }}
          </div>
          <el-divider></el-divider>
        </div>
      </div>
    </el-card>
  </div>
</template>
<script setup lang="ts">
import { User } from '@element-plus/icons-vue'
import { ref, onMounted, reactive } from 'vue'
import weLogo from '@/assets/image/we.png'
import CountTo from '@/components/CountTo/index.vue'
import BarCharts from '@/views/echarts/simple/components/bar.vue'
import { HttpClient } from '@/utils/HttpClient'
import { Logger } from '@/engine/util/Logger'
import { da } from 'element-plus/es/locale'

const goTo = (url) => {
  window.open(url, '_blank')
}
const main_statistics_info = reactive({
  accountNum: 0,
  userNum: 0,
})

const serverInfo = reactive({
  gm_status: 1,
})

const gameInfo = reactive([
  1, 1, 1, 1, 1, 1, 1
])

onMounted(() => {
  HttpClient.get_main_statistics_info((data: object) => {
    main_statistics_info.accountNum = data["accountNum"]
    main_statistics_info.userNum = data["userNum"]
  })
  // HttpClient.get_gm_server_status((data: Array<number>) => {
  //   serverInfo.gm_status = data[0]
  //   for (let i = 0; i < data.length; i++) {
  //     gameInfo[i] = data[i]
  //   }
  // })
})

const onclickset_allserver_status = () => {
  let setStatus: number = serverInfo.gm_status
  if (setStatus == 1) {
    setStatus = 999
  } else {
    setStatus = 1
  }
  HttpClient.set_allserver_status(setStatus, () => {
    serverInfo.gm_status = setStatus;
  })
}


const onclickset_game_status = (gameType: number) => {
  let nowGameInfo = gameInfo[gameType]
  let setStatus: number = nowGameInfo
  if (setStatus == 1) {
    setStatus = 999
  } else {
    setStatus = 1
  }
  HttpClient.set_gameserver_status(gameType, setStatus, () => {
    gameInfo[gameType] = setStatus;
  })
}

const onClick_clear_room =  ()=>{
  HttpClient.kill_all_users()
}

const onClick_clear_room_game = (gameType:number)=>{
  HttpClient.kill_users_by_game(gameType)
}


</script>

<style scoped lang="scss">
@import "./index";
</style>
